﻿package com.tudou.home.model.ad
{
    import com.tudou.ad.events.*;
    import com.tudou.ad.view.*;
    import com.tudou.home.commands.ad.*;
    import com.tudou.home.consts.*;
    import com.tudou.home.model.ad.base.*;
    import flash.geom.*;

    public class AdBackgroundProxy extends AdProxyBase
    {
        public static const NAME:String = "AdBackgroundProxy";

        public function AdBackgroundProxy()
        {
            super(NAME);
            loaderTime = 0;
            return;
        }// end function

        override public function goTransform(param1:uint, param2:uint, param3:Boolean) : void
        {
            view.goTransform(param1, param2, param3);
            return;
        }// end function

        override protected function adErrorEnd() : void
        {
            sendNotification(AdBackgroundCommandSet.ERROR_END);
            return;
        }// end function

        override public function startView() : void
        {
            if (!startViewCommon())
            {
                return;
            }
            view = new AdBackgroundView();
            view.mainWidth = AdSize.BACKGROUND_WIDTH;
            view.mainHeight = AdSize.BACKGROUND_HEIGHT;
            view.bgWidth = AdSize.BACKGROUND_WIDTH;
            view.bgHeight = AdSize.BACKGROUND_HEIGHT;
            view.mainTop = 0;
            view.adItemInfo = adItemInfo;
            view.adThrowInfo = adThrowInfo;
            view.countDownTime = getRemainDt();
            view.isExpand = PlayerConsts.expandStage;
            view.tracker = _tracker;
            view.setStuff(frontStuff);
            view.initToShow();
            createViewListeners();
            var _loc_1:* = PlayerConsts.NORMALSCREEN_RECT;
            goTransform(_loc_1.width, _loc_1.height, false);
            view.startAd();
            return;
        }// end function

        override protected function viewEventHlr(event:AdItemViewEvent) : void
        {
            switch(event.type)
            {
                case AdItemViewEvent.SHOW_START:
                {
                    sendNotification(AdBackgroundCommandSet.SHOW_START);
                    break;
                }
                case AdItemViewEvent.SHOW_END:
                {
                    sendNotification(AdBackgroundCommandSet.SHOW_END);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override protected function frontStuffComplete() : void
        {
            sendNotification(AdBackgroundCommandSet.PREPARE_TO_SHOW);
            return;
        }// end function

        override protected function frontStuffError() : void
        {
            adSkip();
            adErrorEnd();
            return;
        }// end function

    }
}
